<?php


namespace App\Http\Controllers\admin\service;

use Illuminate\Support\Facades\DB;
use App\Http\Controllers\utils\ToolUtil;

class StrategyService
{


    public static function timeControlList($param){

        $sn = ToolUtil::filterStr($param['sn']);
        $batch = DB::table('sn')->where('value',$sn)->value('batch');
        if(empty($batch)){
            return ToolUtil::returnJson(400,'没有数据');
        }

        $leftJoin = " left join auth_admin as a on t.admin_id=a.id ";
        $field = "t.id,a.username,t.start_time,t.end_time,t.create_time,t.batch";
        $data = DB::select("select $field from time_control as t $leftJoin where find_in_set('$batch',t.batch) order by t.id desc ");
        if(count($data)){
            $data = ToolUtil::handleBatch($data,'batch');
            return ToolUtil::returnJson(200,'成功',$data);
        }
        return ToolUtil::returnJson(400,'没有数据');

    }
    

    public static function otherSettingList($param){

        $sn = ToolUtil::filterStr($param['sn']);
        $batch = DB::table('sn')->where('value',$sn)->value('batch');
        if(empty($batch)){
            return ToolUtil::returnJson(400,'没有数据');
        }

        $leftJoin = " left join auth_admin as a on o.admin_id=a.id ";
        $field = "o.id,o.batch,a.username,o.createtime,o.setting_call,o.setting_memory,o.setting_usb,o.setting_navigation,
        o.setting_statusbar,o.setting_tfmedia,o.setting_phones,o.setting_phone,o.status,o.setting_camera,o.setting_tfmedia_format,
        o.setting_clock,o.setting_recording,o.setting_music,o.setting_picture,o.setting_wallpaper,o.setting_file,o.update_time,
        o.setting_bht,o.setting_hotspot,o.qch_restore,o.setting_autotime,o.setting_nav,o.setting_bluetooth,o.setting_context,
        o.setting_bhtvideo,o.setting_browserInput,o.setting_browser";
        $data = DB::select("select $field from other_setting as o $leftJoin where find_in_set('$batch',o.batch) order by o.id desc ");
        if(count($data)){
            $data = ToolUtil::handleBatch($data,'batch');
            return ToolUtil::returnJson(200,'成功',$data);
        }
        return ToolUtil::returnJson(400,'没有数据');

    }



}
